<template>
  <div class="todoList-container center">
    <h2>
      代办项
      <Count>
        {{ todoNum }}
      </Count>
    </h2>
    <ul>
      <!-- todo-list -->
      <template v-for="item in todoList">
        <component :is="item.comName" :key="item.id" :item="item" v-if="item.finished === false"> </component>
      </template>
      <!-- <component :is="item.comName" v-for="item in todoList" :key="item.id" :item="item"> </component> -->
    </ul>
  </div>
</template>

<script>
import { mapGetters, mapState } from 'vuex'
import Count from '@/components/Count/Count.vue'
import ListItem from '@/components/ListItem/ListItem.vue'
export default {
  components: { Count, ListItem },
  created() {
    this.$store.dispatch('get_todoList')
  },
  computed: {
    ...mapGetters(['todoNum']),
    ...mapState(['todoList'])
  }
}
</script>

<style lang="less" scoped>
h2 {
  position: relative;
}
</style>
